{{include file ="header.tpl"}}
{{include file ="navibar.tpl"}}
{{include file ="sidebar.tpl"}}
<link rel="stylesheet" type="text/css"
	href="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript"
	src="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<div class="content">

<div class="container-fluid">
	<div class="row-fluid">
		<div class="bb-alert alert alert-info" style="display: none;">
			<span>操作成功</span>
		</div>


<script type="text/javascript">

	$(document).ready(function(){
		$('#win_add').window('close');
	});

	function newUser(){
		$('#win_add').window('open');
		$("#div_add").show();
		$("#div_edit").hide();
		$("#form").form('clear');
		$("#user_name").attr("readonly",false);

	}
	function editUser(){
		var select = getSelectUser();
		if(select == null || select.length == 0 ){
			$.messager.alert('错误','请选择要修改的记录!');
			return;
		}

		$('#win_add').window('open');
		$("#div_edit").show();
		$("#div_add").hide();
		$("#form").form('clear');
		$("#form").form('load',select[0]);

		$("#user_name").attr("readonly",true);

	}
	function removeUser(){

		$.messager.confirm('删除确定','确定要删除当前选择的记录!',function(r){
		    if (r){
		    	var select = getSelectUser();
				if(select == null || select.length == 0 ){
					$.messager.alert('错误','请选择要删除的记录!');
					return;
				}
				$.ajax({
		            type: "POST",
		            dataType: "json",
		            url: '{{$web_root}}user/delete',
		            data: { id: select[0].id },
		            success: function (data) {
		                $.messager.alert("消息", "删除成功!", "info");
		             	$('#grid').datagrid('reload');
		            },
		            error: function () {
		            }
		        });
		    }
		});

	}
	function addNewUser(){

		  if(!$('#form').form('validate')){
		        return;
		     }
		$('#form').form({
		    url:'{{$web_root}}user/add',
		    type: "POST",
            dataType: "json",
		    onSubmit: function(){
		        //进行表单验证
		        //如果返回false阻止提交
		    },
		    success:function(data){
			    if(data <0){
			    	$.messager.alert('错误','存在相同的用户!');
			    	return;
				 }
		    	win_close();
		    	$.messager.alert('成功','添加成功!');
		    	$('#grid').datagrid('reload');

		    }
		});
		//提交表单
		$('#form').submit();
	}
	function editCurUser(){
		  if(!$('#form').form('validate')){
		        return;
		     }
		  win_close();
		$.ajax({
            type: "POST",
            dataType: "json",
            url: '{{$web_root}}user/editData',
           	data: $("#form").serialize(),
            success: function (data) {

		    	$.messager.alert('成功','修改成功!');
             	$('#grid').datagrid('reload');
            },
            error: function () {
            }
        });
	}
	function win_close(){
		$('#win_add').window('close');
	}


	function getSelectUser(){
		var select  = $("#grid").datagrid('getSelections');
		if(select == null || select.length == 0 ){
			return null;
		}
		return select;
	}
</script>
{{$admin_action_alert}}
{{$admin_quick_note}}

	<div class="block">
        <a href="#page-menu" class="block-heading" data-toggle="collapse">信息查询</a>
        <div id="page-menu" class="block-body collapse in">
            <br/>
            <form class="form-search">
                  <div class="input-prepend">
                     <span class="add-on">设备名称</span>
                     <input class="input-medium" id="prependedInput" type="text" placeholder="设备名称">
                  </div>
                  <div class="input-prepend">
                     <span class="add-on">序列号</span>
                     <input class="input-medium" id="prependedInput" type="text" placeholder="序列号">
                  </div>
                  <div class="input-prepend">
                      <span class="add-on">天线系统</span>
                      <input class="input-medium" id="prependedInput" type="text" placeholder="天线系统">
                  </div>
                  <div class="input-prepend">
                      <span class="add-on">设备状态</span>
                      <input class="input-medium" id="prependedInput" type="text" placeholder="设备状态">
                  </div>
                  <button type="submit" class="btn btn-primary">查询</button>
            </form>
		</div>
    </div>

    <div class="block">
        <a href="#page-stats" class="block-heading" data-toggle="collapse">当前设备信息</a>
		<div class="row-fluid">
			<div class="bb-alert alert alert-info" style="display: none;">
				<span>操作成功</span>
			</div>
			<!--- START 以上内容不需更改，保证该TPL页内的标签匹配即可 --->

			<form class="form-inline">

			</form>
			<table id="grid"
				data-options="url:'ticket/getpage',fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: 1300px; height: 350px"
				toolbar="#toolbar" iconCls="icon-save" pagination="true"
				  rownumbers="true">
				<thead>
					<tr>
					    <th data-options="field:'passwd',hidden:true"></th>
						<th data-options="field:'DEVICE_ID',checkbox:true"></th>
						<th data-options="field:'DEVICE_NAME',width:100">设备名称</th>
						<th data-options="field:'DEVICE_TYPE',width:100">设备型号</th>
						<th data-options="field:'LOCATION',width:100">序列号</th>
						<th data-options="field:'WORK_TYPE',width:100">业务类型</th>
						<th data-options="field:'SATELLITE',width:100">对准卫星</th>
						<th data-options="field:'LOCATION',width:100">地理位置</th>
						<th data-options="field:'LOCATION',width:100">故障记录</th>
						<th data-options="field:'LOCATION',width:100">巡检记录</th>
						<th data-options="field:'LOCATION',width:100">操作</th>
					</tr>
				</thead>
			</table>

			<div id="toolbar">
				<a href="#" class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="newUser()">在线添加</a> <a href="#"
					class="easyui-linkbutton" iconCls="icon-edit" plain="true"
					onclick="editUser()">批量导入</a>
			</div>
			<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
			{{include file="footer.tpl" }}